package com.wolfeyes.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.wolfeyes.system.mapper.SysLogMapper;
import com.wolfeyes.system.domain.entity.SysLogDO;
import com.wolfeyes.system.domain.entity.PageDO;
import com.wolfeyes.system.service.SysLogService;
import com.wolfeyes.common.utils.network.webpage.Query;

/**
 * @see Talk is cheap, Show me the code. -- Linus Torvalds
 * @title web系统日志入库落盘服务层-实现类
 * @author yanyljava
 * @email yanyljava@qq.com
 * @create 2022-01-15 10:21
 */
@Service
public class SysLogServiceImpl implements SysLogService {
	
	@Autowired
	SysLogMapper sysLogMapper;

	@Async
	@Override
	public void save(SysLogDO logDO) {
		sysLogMapper.save(logDO);
	}

	@Override
	public PageDO<SysLogDO> queryList(Query query) {
		int total = sysLogMapper.count(query);
		List<SysLogDO> logs = sysLogMapper.list(query);
		PageDO<SysLogDO> page = new PageDO<>();
		page.setTotal(total);
		page.setRows(logs);
		return page;
	}

	@Override
	public int remove(Long id) {
		int count = sysLogMapper.remove(id);
		return count;
	}

	@Override
	public int batchRemove(Long[] ids){
		return sysLogMapper.batchRemove(ids);
	}
}
